use lazy_static::lazy_static;
use std::collections::HashMap;

/// # 债券基本信息表头
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum BondBaseInfoField {
    SecurityCode,
    SecurityNameAbbr,
    ConvertStockCode,
    SecurityShortName,
    RATING,
    PublicStartDate,
    ActualIssueScale,
    OnlineGeneralLwr,
    ListingDate,
    ExpireDate,
    BondExpire,
    InterestRateExplain,
}
// Define a lazy_static HashMap with the field identifiers and their corresponding comments
lazy_static! {
    static ref FIELD_COMMENTS: HashMap<BondBaseInfoField, &'static str> = {
        let mut map = HashMap::new();
        map.insert(BondBaseInfoField::SecurityCode, "债券代码");
        map.insert(BondBaseInfoField::SecurityNameAbbr, "债券名称");
        map.insert(BondBaseInfoField::ConvertStockCode, "正股代码");
        map.insert(BondBaseInfoField::SecurityShortName, "正股名称");
        map.insert(BondBaseInfoField::RATING, "债券评级");
        map.insert(BondBaseInfoField::PublicStartDate, "申购日期");
        map.insert(BondBaseInfoField::ActualIssueScale, "发行规模(亿)");
        map.insert(BondBaseInfoField::OnlineGeneralLwr, "网上发行中签率(%)");
        map.insert(BondBaseInfoField::ListingDate, "上市日期");
        map.insert(BondBaseInfoField::ExpireDate, "到期日期");
        map.insert(BondBaseInfoField::BondExpire, "期限(年)");
        map.insert(BondBaseInfoField::InterestRateExplain, "利率说明");
        map
    };
}

impl BondBaseInfoField {
    // Method to get the comment for a field
    fn _get_field_comment(&self) -> &'static str {
        FIELD_COMMENTS
            .get(self)
            .copied()
            .unwrap_or("Comment not found")
    }
}

#[derive(Debug, PartialEq, Eq, Hash)]
enum EastmoneyRankField {
    F12,
    F14,
    F3,
    F15,
    F4,
    F5,
    F6,
    F18,
}

// Define a static HashMap with the EastmoneyRank field identifiers and their corresponding comments
lazy_static! {
    static ref EASTMONEY_RANK: HashMap<EastmoneyRankField, &'static str> = {
        let mut map = HashMap::new();
        map.insert(EastmoneyRankField::F12, "代码");
        map.insert(EastmoneyRankField::F14, "名称");
        map.insert(EastmoneyRankField::F3, "涨跌幅");
        map.insert(EastmoneyRankField::F15, "最新价");
        map.insert(EastmoneyRankField::F4, "涨跌额");
        map.insert(EastmoneyRankField::F5, "成交量");
        map.insert(EastmoneyRankField::F6, "成交额");
        map.insert(EastmoneyRankField::F18, "昨日收盘");
        map
    };
}

impl EastmoneyRankField {
    // Method to get the comment for a field
    fn _get_field_comment(&self) -> &'static str {
        match EASTMONEY_RANK.get(self) {
            Some(comment) => *comment,
            None => "Comment not found",
        }
    }
}

/// # 股票基本信息表头
#[derive(Debug, PartialEq, Eq, Hash)]
enum EastmoneyStockBaseInfoField {
    F57,
    F58,
    F162,
    F167,
    F127,
    F116,
    F117,
    F198,
    F173,
    F187,
    F105,
    F186,
}

// Define a static HashMap with the EastmoneyStockBaseInfo field identifiers and their corresponding comments
lazy_static! {
    static ref EASTMONEY_STOCK_BASE_INFO_FIELDS: HashMap<EastmoneyStockBaseInfoField, &'static str> = {
        let mut map = HashMap::new();
        map.insert(EastmoneyStockBaseInfoField::F57, "股票代码");
        map.insert(EastmoneyStockBaseInfoField::F58, "股票名称");
        map.insert(EastmoneyStockBaseInfoField::F162, "市盈率(动)");
        map.insert(EastmoneyStockBaseInfoField::F167, "市净率");
        map.insert(EastmoneyStockBaseInfoField::F127, "所处行业");
        map.insert(EastmoneyStockBaseInfoField::F116, "总市值");
        map.insert(EastmoneyStockBaseInfoField::F117, "流通市值");
        map.insert(EastmoneyStockBaseInfoField::F198, "板块编号");
        map.insert(EastmoneyStockBaseInfoField::F173, "ROE");
        map.insert(EastmoneyStockBaseInfoField::F187, "净利率");
        map.insert(EastmoneyStockBaseInfoField::F105, "净利润");
        map.insert(EastmoneyStockBaseInfoField::F186, "毛利率");
        map
    };
}
